package com.prs.crm.dao.oa.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.dao.oa.NewsCollectTypeDao;
import com.prs.crm.domain.oa.MyFile;
import com.prs.crm.domain.oa.NewsCollectType;

public class NewsCollectTypeDaoImpl extends BaseDaoImpl<NewsCollectType> implements NewsCollectTypeDao{

	@Override
	public NewsCollectType getTypeByName(String name) {
		Criteria criteria = this.getSession().createCriteria(NewsCollectType.class);
		criteria.add(Restrictions.eq("name", name));
		List<NewsCollectType> list = criteria.list();
		if(list.size()!=0){
			return list.get(0);
		}else{
			return null;
		}
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<NewsCollectType> getAll() {
		Criteria criteria = this.getSession().createCriteria(NewsCollectType.class);
		return criteria.list();
	}

}
